package com.example.timer;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;

public class Timer extends ListActivity {
    public static final int MENU_SAVE = 0;
    public static final int MENU_ABOUT = 1;
    public static final int MENU_EXIT = 2;
    
    public static final int STOPWATCH_ID = 0;
    public static final int TIMER_ID = 1;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        registerForContextMenu(getListView());
    }
    
    public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
		super.onCreateContextMenu(menu, v, menuInfo);
		menu.add(0, STOPWATCH_ID, 0, "Stopwatch");
		menu.add(0, TIMER_ID, 0,  "Timer");
	}

	public boolean onContextItemSelected(MenuItem item) {
		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
		switch (item.getItemId()) {
		case STOPWATCH_ID:
			return true;
		case TIMER_ID:
			return true;
		default:
			return super.onContextItemSelected(item);
		}
	}
    
    public boolean onCreateOptionsMenu(Menu menu){
    	menu.add(0, MENU_SAVE, 0, "Save");
    	menu.add(0, MENU_ABOUT, 0, "About");
    	menu.add(0, MENU_EXIT, 0, "Exit");
    	return true;
    }
    
    public boolean onOptionsItemSelected(MenuItem item){
    	switch(item.getItemId()){
    	case MENU_SAVE:
    		return true;
    	case MENU_ABOUT:
    		return true;
    	case MENU_EXIT:
    		return true;
    	}
    	return false;
    }
}